(function () { 'use strict'
  var createApp = function (mydatas) {
	  console.log(mydatas);
    // ---------------------
    // 开始常用的应用代码
    // ---------------------
    // 主要的Vue实例必须返回，并且有一个根节点在id "app"上，这样客户端可以加载它。
  // datas=[{'id':3,'author':'张珊','updatedAt':'2017-08-01','title':'你好'},
	// 		{'id':4,'author':'李思','updatedAt':'2017-08-01','title':'你好'},
	//    {'id':5,'author':'李思','updatedAt':'2017-08-01','title':'你好'}
	// 	];
   
    return new Vue({
      template:'<div id="app">'
	  +'<div class="add_header"><p class="add" @click="addData">新增</p></div>'
	          +'<table id="indestry_info" class="indestry_info_table" cellpadding="10" cellspacing="0" width="100%">'
	        + '<thead>'+
					'<tr>'+
						'<th class="sorting_disabled number" rowspan="1" colspan="1">id</th>'+
						'<th class="sorting_disabled title" rowspan="1" colspan="1">标题</th>'+
						'<th class="sorting_disabled publisher" rowspan="1" colspan="1">发布人</th>'+
						'<th class="sorting_disabled publishdata" rowspan="1" colspan="1">发布时间</th>'+
						'<th class="sorting_disabled" rowspan="1" colspan="1">操作</th>'+
						'<th class="sorting_disabled id" rowspan="1" colspan="1"></th>'+
					'</tr>'+
				'</thead>'+
				'<tbody>'+
						'<tr  v-for="column in columns">'+
							'<td class="number">{{column.id}}</td>'+
							'<td class=" title">{{column.title}}</td>'+
							'<td class="publisher">{{column.author}}</td>'+
							'<td class="publishdata">{{column.updatedAt}}</td>'+
							'<td><div class="operation">'
			                   +'<span class="edut"  @click="updateData(column.id)">编辑</span>'
			                   +'<span class="delete" @click="deleteData(column.id)">删除</span>'
							+'</div></td>'+
							'<td class="id"></td>'+
						'</tr>'+
				'<tbody>'
			+'</table></div>',
      data: {
			 counter: 0,
			items: [
			  {message: 'Foo' },
			  {message: 'Bar' }
			],
            columns:mydatas
      },
	  methods:{
	   updateData:function(id){
		   window.location.href = "/views/AddIndustryStandard/AddIndustryStandard.html?id="+id;
	   },
	  deleteData:function(id){
		   var _data=this.columns;
	     $.ajax({
			url: '/hybz/delete',
			type: 'get',
			data: "id="+id,
			cache: false,
			contentType: false, //不可缺参数
			processData: false, //不可缺参数
			success: function(datas) {
				var _key=0;
			   $.each(_data,function(key,val){
			       if(val.id==id){
				       _key=key; 
				   }
			   });
			   _data.splice(_key,1);
			},
			error: function() {
				console.log('error');
			}
                    });
		
	   },
	   addData:function(){
		  window.location.href = "/views/AddIndustryStandard/AddIndustryStandard.html";
		 //跳转修改页面

	   },
	  onClicked: function(e){
		  alert('child clicked');
    }
  },created: function () {
	    console.log(mydatas);
        this.columns=mydatas;
      }
    })
    // -------------------
    // 结束常用的应用代码
    // -------------------
  }
  if (typeof module !== 'undefined' && module.exports) {
    module.exports = createApp
  } else {
    this.app = createApp()
  }
}).call(this)